@extends('backstage.layout.master')
@section('title', '添加子模块')
@section('style')
@stop
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try {
                ace.settings.check('breadcrumbs', 'fixed')
            } catch (e) {
            }
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="backstage/home">主页</a>
            </li>
            <li>
                添加子模块
            </li>
        </ul><!-- .breadcrumb -->
    </div>

    <div class="page-content">
        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->
                <div class="page-header">
                    <h1>
                        添加子模块
                    </h1>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <form id="myform" class="form-horizontal" role="form" action="backstage/module/add-module" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
                            <div class="form-group ">
                                <label class="col-sm-4 control-label no-padding-right"> 父级模块 </label>
                                <div class="col-sm-4">
                                    <select name="" class="form-control">
                                        <option selected >发现页模块</option>
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"> </div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group product_form {{$errors->first('find_module_name')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 模块名称 </label>
                                <div class="col-sm-4">
                                    <input type="text" name="find_module_name" value="{{old('find_module_name')}}" id="find_module_name" placeholder="模块名称"
                                           class="width-100">
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('find_module_name')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group product_form {{$errors->first('app_id')!=""?'has-error':''}}">
                                <label class="col-sm-4 control-label no-padding-right"> 关联模块 </label>
                                <div class="col-sm-4">
                                    <select name="app_id" class="form-control" id="app_id">
                                        @foreach($relate_modules as $relate_module)
                                            <option value="{{$relate_module['app_id']}}">{{$relate_module['app_cn_name']}}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline">{{$errors->first('app_id')}}</div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="form-group product_form" id="temp-type" style="display: none;">
                                <label class="col-sm-4 control-label no-padding-right"> 推荐模板类别 </label>
                                <div class="col-sm-4">
                                    <select name="redirect_module" class="form-control" id="categorys">

                                    </select>
                                </div>
                                <div class="col-sm-4">
                                    <div class="help-block col-xs-12 col-sm-reset inline"></div>
                                </div>
                            </div>
                            <div class="space-4"></div>
                            <div class="clearfix form-actions">
                                <div class="col-md-offset-5">
                                    <button class="btn btn-info" type="submit">
                                        <i class="icon-ok bigger-110"></i>
                                        保存
                                    </button>

                                    &nbsp; &nbsp; &nbsp;
                                    <button class="btn" type="reset">
                                        <i class="icon-undo bigger-110"></i>
                                        重置
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div>
                <!-- PAGE CONTENT ENDS -->
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
@stop
@section('script')
<script>
    var _token = '{{csrf_token()}}';
    $(function(){
        $("#app_id").change(function(){
            var app_id = $("#app_id option:checked").val();
            if(app_id == 3){
                //产品模块
                $.post("backstage/module/search-categorys", {
                    _token: _token
                }, function (data, status) {
                    var html='';
                    for(var a=0;a<data.length;a++) {
                        html+='<option value="' + data[a].product_temp_category_id + '">'+ data[a].name +'</option><br />';
                    }
                    $("#categorys").empty();
                    $("#categorys").append(html);
                    $("#temp-type").show();
                });
            }
        });
    });
</script>
@stop